﻿using System;
using UnityEngine;

namespace UnityStandardAssets.CinematicEffects
{
	// Token: 0x02000461 RID: 1121
	[Serializable]
	public class FXAA : IAntiAliasing
	{
		// Token: 0x170001DE RID: 478
		// (get) Token: 0x060017E3 RID: 6115 RVA: 0x00065771 File Offset: 0x00063B71
		private Shader shader
		{
			get
			{
				if (this.m_Shader == null)
				{
					this.m_Shader = Shader.Find("Hidden/Fast Approximate Anti-aliasing");
				}
				return this.m_Shader;
			}
		}

		// Token: 0x170001DF RID: 479
		// (get) Token: 0x060017E4 RID: 6116 RVA: 0x0006579A File Offset: 0x00063B9A
		public Material material
		{
			get
			{
				if (this.m_Material == null)
				{
					this.m_Material = ImageEffectHelper.CheckShaderAndCreateMaterial(this.shader);
				}
				return this.m_Material;
			}
		}

		// Token: 0x170001E0 RID: 480
		// (get) Token: 0x060017E5 RID: 6117 RVA: 0x000657C4 File Offset: 0x00063BC4
		// (set) Token: 0x060017E6 RID: 6118 RVA: 0x000657CC File Offset: 0x00063BCC
		public bool validSourceFormat { get; private set; }

		// Token: 0x060017E7 RID: 6119 RVA: 0x000657D5 File Offset: 0x00063BD5
		public void OnEnable(AntiAliasing owner)
		{
			if (!ImageEffectHelper.IsSupported(this.shader, true, false, owner))
			{
				owner.enabled = false;
			}
		}

		// Token: 0x060017E8 RID: 6120 RVA: 0x000657F1 File Offset: 0x00063BF1
		public void OnDisable()
		{
			if (this.m_Material != null)
			{
				UnityEngine.Object.DestroyImmediate(this.m_Material);
			}
		}

		// Token: 0x060017E9 RID: 6121 RVA: 0x0006580F File Offset: 0x00063C0F
		public void OnPreCull(Camera camera)
		{
		}

		// Token: 0x060017EA RID: 6122 RVA: 0x00065811 File Offset: 0x00063C11
		public void OnPostRender(Camera camera)
		{
		}

		// Token: 0x060017EB RID: 6123 RVA: 0x00065814 File Offset: 0x00063C14
		public void OnRenderImage(Camera camera, RenderTexture source, RenderTexture destination)
		{
			this.material.SetVector("_QualitySettings", new Vector3(this.preset.qualitySettings.subpixelAliasingRemovalAmount, this.preset.qualitySettings.edgeDetectionThreshold, this.preset.qualitySettings.minimumRequiredLuminance));
			this.material.SetVector("_ConsoleSettings", new Vector4(this.preset.consoleSettings.subpixelSpreadAmount, this.preset.consoleSettings.edgeSharpnessAmount, this.preset.consoleSettings.edgeDetectionThreshold, this.preset.consoleSettings.minimumRequiredLuminance));
			Graphics.Blit(source, destination, this.material, 0);
		}

		// Token: 0x04000D21 RID: 3361
		private Shader m_Shader;

		// Token: 0x04000D22 RID: 3362
		private Material m_Material;

		// Token: 0x04000D23 RID: 3363
		[SerializeField]
		[HideInInspector]
		public FXAA.Preset preset = FXAA.Preset.defaultPreset;

		// Token: 0x04000D24 RID: 3364
		public static FXAA.Preset[] availablePresets = new FXAA.Preset[]
		{
			FXAA.Preset.extremePerformancePreset,
			FXAA.Preset.performancePreset,
			FXAA.Preset.defaultPreset,
			FXAA.Preset.qualityPreset,
			FXAA.Preset.extremeQualityPreset
		};

		// Token: 0x02000462 RID: 1122
		[Serializable]
		public struct QualitySettings
		{
			// Token: 0x04000D26 RID: 3366
			[Tooltip("The amount of desired sub-pixel aliasing removal. Effects the sharpeness of the output.")]
			[Range(0f, 1f)]
			public float subpixelAliasingRemovalAmount;

			// Token: 0x04000D27 RID: 3367
			[Tooltip("The minimum amount of local contrast required to qualify a region as containing an edge.")]
			[Range(0.063f, 0.333f)]
			public float edgeDetectionThreshold;

			// Token: 0x04000D28 RID: 3368
			[Tooltip("Local contrast adaptation value to disallow the algorithm from executing on the darker regions.")]
			[Range(0f, 0.0833f)]
			public float minimumRequiredLuminance;
		}

		// Token: 0x02000463 RID: 1123
		[Serializable]
		public struct ConsoleSettings
		{
			// Token: 0x04000D29 RID: 3369
			[Tooltip("The amount of spread applied to the sampling coordinates while sampling for subpixel information.")]
			[Range(0.33f, 0.5f)]
			public float subpixelSpreadAmount;

			// Token: 0x04000D2A RID: 3370
			[Tooltip("This value dictates how sharp the edges in the image are kept; a higher value implies sharper edges.")]
			[Range(2f, 8f)]
			public float edgeSharpnessAmount;

			// Token: 0x04000D2B RID: 3371
			[Tooltip("The minimum amount of local contrast required to qualify a region as containing an edge.")]
			[Range(0.125f, 0.25f)]
			public float edgeDetectionThreshold;

			// Token: 0x04000D2C RID: 3372
			[Tooltip("Local contrast adaptation value to disallow the algorithm from executing on the darker regions.")]
			[Range(0.04f, 0.06f)]
			public float minimumRequiredLuminance;
		}

		// Token: 0x02000464 RID: 1124
		[Serializable]
		public struct Preset
		{
			// Token: 0x170001E1 RID: 481
			// (get) Token: 0x060017ED RID: 6125 RVA: 0x0006593D File Offset: 0x00063D3D
			public static FXAA.Preset extremePerformancePreset
			{
				get
				{
					return FXAA.Preset.s_ExtremePerformance;
				}
			}

			// Token: 0x170001E2 RID: 482
			// (get) Token: 0x060017EE RID: 6126 RVA: 0x00065944 File Offset: 0x00063D44
			public static FXAA.Preset performancePreset
			{
				get
				{
					return FXAA.Preset.s_Performance;
				}
			}

			// Token: 0x170001E3 RID: 483
			// (get) Token: 0x060017EF RID: 6127 RVA: 0x0006594B File Offset: 0x00063D4B
			public static FXAA.Preset defaultPreset
			{
				get
				{
					return FXAA.Preset.s_Default;
				}
			}

			// Token: 0x170001E4 RID: 484
			// (get) Token: 0x060017F0 RID: 6128 RVA: 0x00065952 File Offset: 0x00063D52
			public static FXAA.Preset qualityPreset
			{
				get
				{
					return FXAA.Preset.s_Quality;
				}
			}

			// Token: 0x170001E5 RID: 485
			// (get) Token: 0x060017F1 RID: 6129 RVA: 0x00065959 File Offset: 0x00063D59
			public static FXAA.Preset extremeQualityPreset
			{
				get
				{
					return FXAA.Preset.s_ExtremeQuality;
				}
			}

			// Token: 0x04000D2D RID: 3373
			[FXAA.Preset.LayoutAttribute]
			public FXAA.QualitySettings qualitySettings;

			// Token: 0x04000D2E RID: 3374
			[FXAA.Preset.LayoutAttribute]
			public FXAA.ConsoleSettings consoleSettings;

			// Token: 0x04000D2F RID: 3375
			private static readonly FXAA.Preset s_ExtremePerformance = new FXAA.Preset
			{
				qualitySettings = new FXAA.QualitySettings
				{
					subpixelAliasingRemovalAmount = 0f,
					edgeDetectionThreshold = 0.333f,
					minimumRequiredLuminance = 0.0833f
				},
				consoleSettings = new FXAA.ConsoleSettings
				{
					subpixelSpreadAmount = 0.33f,
					edgeSharpnessAmount = 8f,
					edgeDetectionThreshold = 0.25f,
					minimumRequiredLuminance = 0.06f
				}
			};

			// Token: 0x04000D30 RID: 3376
			private static readonly FXAA.Preset s_Performance = new FXAA.Preset
			{
				qualitySettings = new FXAA.QualitySettings
				{
					subpixelAliasingRemovalAmount = 0.25f,
					edgeDetectionThreshold = 0.25f,
					minimumRequiredLuminance = 0.0833f
				},
				consoleSettings = new FXAA.ConsoleSettings
				{
					subpixelSpreadAmount = 0.33f,
					edgeSharpnessAmount = 8f,
					edgeDetectionThreshold = 0.125f,
					minimumRequiredLuminance = 0.06f
				}
			};

			// Token: 0x04000D31 RID: 3377
			private static readonly FXAA.Preset s_Default = new FXAA.Preset
			{
				qualitySettings = new FXAA.QualitySettings
				{
					subpixelAliasingRemovalAmount = 0.75f,
					edgeDetectionThreshold = 0.166f,
					minimumRequiredLuminance = 0.0833f
				},
				consoleSettings = new FXAA.ConsoleSettings
				{
					subpixelSpreadAmount = 0.5f,
					edgeSharpnessAmount = 8f,
					edgeDetectionThreshold = 0.125f,
					minimumRequiredLuminance = 0.05f
				}
			};

			// Token: 0x04000D32 RID: 3378
			private static readonly FXAA.Preset s_Quality = new FXAA.Preset
			{
				qualitySettings = new FXAA.QualitySettings
				{
					subpixelAliasingRemovalAmount = 1f,
					edgeDetectionThreshold = 0.125f,
					minimumRequiredLuminance = 0.0625f
				},
				consoleSettings = new FXAA.ConsoleSettings
				{
					subpixelSpreadAmount = 0.5f,
					edgeSharpnessAmount = 4f,
					edgeDetectionThreshold = 0.125f,
					minimumRequiredLuminance = 0.04f
				}
			};

			// Token: 0x04000D33 RID: 3379
			private static readonly FXAA.Preset s_ExtremeQuality = new FXAA.Preset
			{
				qualitySettings = new FXAA.QualitySettings
				{
					subpixelAliasingRemovalAmount = 1f,
					edgeDetectionThreshold = 0.063f,
					minimumRequiredLuminance = 0.0312f
				},
				consoleSettings = new FXAA.ConsoleSettings
				{
					subpixelSpreadAmount = 0.5f,
					edgeSharpnessAmount = 2f,
					edgeDetectionThreshold = 0.125f,
					minimumRequiredLuminance = 0.04f
				}
			};

			// Token: 0x02000465 RID: 1125
			[AttributeUsage(AttributeTargets.Field)]
			public class LayoutAttribute : PropertyAttribute
			{
			}
		}
	}
}
